package com.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultEntity {
    private Integer code;
    private String msg;
    private Object data;

    public static ResultEntity ok(){
        ResultEntity result = new ResultEntity(200,"操作成功",null);
        return result;
    }

    public static ResultEntity ok(Object data){
        ResultEntity result = new ResultEntity(200,"操作成功",data);
        return result;
    }

    public static ResultEntity ok(String msg,Object data){
        ResultEntity result = new ResultEntity(200,msg,data);
        return result;
    }

    public static ResultEntity error(){
        ResultEntity result = new ResultEntity(500,"操作失败",null);
        return result;
    }

    public static ResultEntity error(Integer code){
        ResultEntity result = new ResultEntity(code,"操作失败",null);
        return result;
    }

    public static ResultEntity error(Integer code,String msg){
        ResultEntity result = new ResultEntity(code,msg,null);
        return result;
    }
}
